package com.itheima.Jiuye12;

import java.io.*;
import java.util.ArrayList;

public class XuliDemo {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        Student stu = new Student("王五",25);
        Student stu1 = new Student("李四",24);
        Student stu2 = new Student("赵六",26);
        //创建对象输出流
        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("mJiuYe\\b.txt"));
        ArrayList<Student> list = new ArrayList<>();
        list.add(stu);
        list.add(stu1);
        list.add(stu2);
        oos.writeObject(list);
        oos.close();

        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("mJiuYe\\b.txt"));
          ArrayList<Student> list1 =  (ArrayList<Student>)ois.readObject();
        for (Student student : list1) {
            System.out.println(student);
        }
        ois.close();
    }
}
